package Try;

import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        while (a%b!=0) {
            int tmp = a%b;
            a = b;
            b = tmp;
        }
        System.out.println(b);
    }
}
